{extend name="base/base" /}
{block name="style"}
<style type="text/css">

</style>
{/block}
{block name="content"}
  <div class="layui-form-item layui-form-pane">
      <div class="layui-inline">
          <label class="layui-form-label">用户ID</label>
          <div class="layui-input-inline">
              <input type="text" name="uid" autocomplete="off" class="layui-input" id='uid'>
          </div>
      </div>
      <div class="layui-inline">
          <label class="layui-form-label">用户名</label>
          <div class="layui-input-inline">
              <input type="text" name="username" autocomplete="off" class="layui-input" id='username'>
          </div>
      </div>
    <!--   <div class="layui-inline">
          <label class="layui-form-label">电话</label>
          <div class="layui-input-inline">
              <input type="text" name="phone" autocomplete="off" class="layui-input" id='phone'>
          </div>
      </div> -->
      <div class="layui-inline">
        <div class="demoTable">
          <button class="layui-btn" data-type="reload">搜索</button>
        </div>
      </div>
  <table id="table" lay-filter="table"></table> 
</div>
{/block}
{block name="script"}
<script>
layui.use(['table', 'laydate'], function(){
  var table = layui.table;
  var laydate = layui.laydate;
  table.render({
    elem: '#table'
    ,height: 'full-200'
    ,url: '/admin/invest/hashrateList/' //数据接口
    ,limit:20
    ,page: true //开启分页
    ,id:'reload'
    ,cols: [[ //表头
        {field:'uid', title: '用户ID', width: 100}
        ,{field:'username', title: '用户名', width: 200}
        ,{field:'hashrate', title: '矿机算力', width: 200}
        ,{field:'invite_hashrate', title: '直推算力', width: 200}
        ,{field:'dicode_hashrate', title: '双轨算力', width: 200}
        ,{field:'total_hashrate', title: '总算力', width: 200}
        ,{field:'profit', title: '收益', width: 200}
        ,{field:'date', title: '统计时间', width: 200}
         ,{field:'is_active', title: '矿机状态', width: 250,templet: function(d){
         if (d.is_active == 1) {
            return '<span style="color:red">已激活</span>'
          }
          if (d.is_active == 0) {
            return '<span style="color:blue">待激活</span>'
          }
        }}
        // ,{title: '操作', toolbar: '#edit', width: 200}
    ]]
  });
  // 搜索
  var $ = layui.$, active = {
        reload: function(){
            table.reload('reload', {
                where: {
                    username: $('#username').val(),
                    uid: $('#uid').val(),
                    status: $('#status').val(),
                    phone:$('#phone').val()
                }
            });
        }
    };
    $('.demoTable .layui-btn').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';

  });

  //日期
  laydate.render({
    elem: '#start_time'
  });
  laydate.render({
    elem: '#end_time'
  });
});
</script>
{/block}
